<script setup lang='ts'>
import { inject } from 'vue';


const getMoney = inject("money", 0)
const cost = inject<(m: number) => void>("cost")

const costMoney = () => {
    if (cost) {
        cost(5)
    }
}

</script>

<template>
    <h3>我是孙子</h3>
    <p>爷爷给孙子的零花钱：{{ getMoney }}</p>
    <button @click="costMoney">买一支雪糕</button>
</template>

<style scoped></style>